package com.gba.mark.user.controller;

import com.gba.mark.user.service.user.IUserService;
import com.gba.mark.util.ResponseUtil;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService userService;

    /**
     * author: zhuzheyu
     * date: 2021-05-23
     * description: 用户注册
     */
    @PostMapping("/register")
    public ResponseUtil<String> register(@RequestParam String username,
                                         @RequestParam String phoneNum,
                                         @RequestParam String password,
                                         @RequestParam String password2) {
        return new ResponseUtil<>(HttpStatus.OK,
                userService.register(username, phoneNum, password, password2));

    }
    /*
      用户找回密码
     */

        @PostMapping("/retrieve")
        public ResponseUtil<String> retrieve (@RequestParam String username,
                                              @RequestParam String phoneNum,
                                              @RequestParam String newPaswd,
                                              @RequestParam String newPaswd2){
            return new ResponseUtil<>(HttpStatus.OK,
                    userService.retrieve(username, phoneNum, newPaswd, newPaswd2));
        }

    }
